home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
net
/
drexxmail.lha
/
demon.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-10-03
|
3KB
|
110 lines
/* demon.rexx - Mail Daemon for DREXXMAIL release 3 */
/* v1.00 9-30-94 */
/* v1.02 10-1-94 Fixed bug that would delete all your*/
/* UNIX mail if your local mailbox was */
/* empty! */
/* v2.00 10-3-94 Added some GUI stuff */
/* This script acts as a mail daemon for DREXXMAIL. */
/* Based loosely on Joe Rumsey's "maildaemon.sh" */
/* for Amiga CSH. This version is configurable */
/* (and killable) thru environment vairables. */
options results
call addlib("rexxreqtools.library",0,-30,0)
/* Some initializations... */
lf = '0a'x
cr = '0d'x
colon='3a'x
semicol='3b'x
qmark='22'x
fonttag=""
address command
/* The meat ... */
call open dlog,"t:debuglog",write
/* dmode - 1=requester mode , 2=timer mode, 0=abort ... default 1 */
dmode = envar('DRMDEMONMODE')
if dmode = "" then dmode = 1
do until envar('DRMABORT') ~=""
remotefile = envar('DRMUNIXDIR')||envar('USERNAME')
localfile = envar('DRMLOCALDIR')||envar('USERNAME')
tempfile = "t:"||envar('USERNAME')
lockfile = tempfile||".LOCK"
msg = "Select an option ..."
if (dmode=1) then dmode = rtezrequest(msg,"_Check mail now|_Timer Mode|_Quit DEMON"," DRexxMail DEMON",fonttag)
if (dmode=0) then call putvar 'DRMABORT',1
if (exists(lockfile)=0)&(dmode~=0) then do
'echo >'lockfile
call open lck,lockfile,write
'dnet:getfiles -dT:' remotefile
call writeln dlog,'dnet:getfiles -dT:' remotefile
flen = 0
mlen = 0
if exists(tempfile) then do
call open clof,tempfile,read
flen = seek(clof,0,'E')
call close clof
end
if exists(localfile) then do
call open mlof,localfile,read
mlen = seek(mlof,0,'E')
call close mlof
end
if flen > 1 then do
if ~exists(localfile) then 'echo >'localfile
'copy 'localfile' t:demon.bak QUIET'
'copy 'tempfile' TO 'localfile
if mlen > 1 then 'join t:demon.bak 'tempfile' AS 'localfile
'echo >'tempfile
call writeln dlog,'dnet:putfiles -d'envar('DRMUNIXDIR') tempfile
call writeln dlog,'echo >'tempfile
'dnet:putfiles -d'envar('DRMUNIXDIR') tempfile
call open ecommand, "T:demon.cmd",write
call writeln ecommand, 'run <NIL: >NIL: 'envar(DRMNOTIFY)
call close ecommand
'execute' "T:demon.cmd"
end
call close lck
'delete 'lockfile' QUIET'
end
delaytime = envar('DRMDELAY')
if delaytime = "" then delaytime = 15
if (dmode=2) then do
'wait 'delaytime' MIN'
end
end
call close dlog
'unsetenv DRMABORT'
msg = "DRexxMail Demon v2.00"||lf||"By Rick Taylor (charlet@eng.clemson.edu)"||lf||"Ended..."
dummy = rtezrequest(msg,"_Ok"," DRexxMail DEMON",fonttag)
exit
envar: procedure
arg evname
epath = "ENV:"||evname
evalue = ""
if exists(epath) then do
call open .envar,epath,read
evalue = readln(.envar)
call close .envar
end
return evalue
putvar: procedure
arg evname,evalue
epath = "ENV:"||evname
call open .envar,epath,write
call writeln .envar,evalue
call close .envar
return 1